package com.stark.wechat.message.in;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.stark.wechat.core.MessageType;
import com.stark.wechat.exception.WechatException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * 加密消息
 *
 * @author <a href="mailto:mengbin@hotmail.com">Ben</a>
 * @version 1.0.0
 * @see <a href="https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Message_encryption_and_decryption.html">开发指南 / 消息与事件推送 / 消息加解密说明</a>
 * @since 2024/5/23
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class EncryptMessage implements Message {

    private static final long serialVersionUID = -5851330117993576613L;

    /**
     * 开发者微信号
     */
    @JacksonXmlProperty(localName = "ToUserName")
    private String toUserName;

    /**
     * 加密后的内容
     */
    @JacksonXmlProperty(localName = "Encrypt")
    private String encrypt;

    /**
     * 加密消息不支持此方法，调用会抛出异常
     */
    @Override
    public String getFromUserName() {
        throw new WechatException("加密消息不支持此方法");
    }

    /**
     * 加密消息不支持此方法，调用会抛出异常
     */
    @Override
    public Long getCreateTime() {
        throw new WechatException("加密消息不支持此方法");
    }

    @Override
    public MessageType getMsgType() {
        return MessageType.encrypt;
    }

}
